<template>
    <div>
        <el-form :model="form">

            <el-form-item label="姓名" :label-width="formLabelWidth">
                <el-input v-model="form.name" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="性别" :label-width="formLabelWidth">
                <el-select v-model="form.sex" placeholder="请选择活动区域">
                    <el-option label="男" value="男"></el-option>
                    <el-option label="女" value="女"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="年龄" :label-width="formLabelWidth">
                <el-input v-model="form.age" autocomplete="off"></el-input>
            </el-form-item>
            <el-button type="primary" @click="add">增加</el-button>
        </el-form>

    </div>
</template>
<script>
import { add } from '@/api/student'
const options = {
    data() {
        return {
            form: {
                name: '',
                sex: '',
                age: ''
            },
            formLabelWidth:"120px"
        }
    },
    methods: {
        async add() {
            const res = await add({ ...this.form });
            console.log(res);
            if (res.data.count > 0) {
                this.$router.push("/student/find")
            } else {
                this.$message({
                    type: 'info',
                    message: '新增失败'
                });
            }
        }
    }
}
export default options;
</script>